package com.justgame.project.cloud.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 文件类型枚举
 * @author ZhouWeiBo
 */
@Getter
@AllArgsConstructor
@SuppressWarnings("all")
public enum FileTypeEnum {
    /* 图片 */
    Image(new String[]{"gif", "jpg", "jpeg", "png", "bmp"}),
    /* FLASH */
    Flash(new String[]{"swf", "flv"}),
    /* 流媒体 */
    Video(new String[]{"swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", "asf", "rm", "rmvb", "mp4", "webm"}),
    /* 其他文件文档 */
    File(new String[]{"doc", "docx", "xls", "xlsx", "ppt", "txt", "zip", "rar", "gz", "bz2"}),
    /* 音频 */
    Audio(new String[]{"mp3", "mid", "wma", "amr", "m4a", "aif", "wav"}),
    /* All */
    System(new String[]{"*"});
    final String[] suffix;

    public boolean isContains(String suf) {
        return Arrays.asList(suffix).contains(suf.toLowerCase());
    }

    /**
     * 获取枚举的KEY
     * @return String
     */
    public String getEnumKey() {
        switch (this) {
            case File:
                return "File";
            case Audio:
                return "Auto";
            case Video:
                return "Video";
            case Flash:
                return "Flash";
            case Image:
                return "Image";
            case System:
                return "System";
            default:
                return "";
        }
    }

}
